﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using log4net;

namespace EverBuy.SocialNetworking.Data.ADODotNetAccessRepository.Abstracts
{
    public abstract class RepositoryBase
    {
        /// <summary>
        /// 
        /// </summary>
        protected static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// 
        /// </summary>
        private static readonly string ConnectionString;

        /// <summary>
        /// Static constructor. Reads the connectionstring from web.config just once.
        /// </summary>
        static RepositoryBase()
        {
            var connectionStringName = ConfigurationManager.AppSettings.Get("ConnectionStringName");
            ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
        }

        ///// <summary>
        ///// Creates the Context using the current connectionstring.
        ///// </summary>
        ///// <remarks>
        ///// Gof pattern: Factory method. 
        ///// </remarks>
        ///// <returns>SocialNetwork Entities context.</returns>
        //public static SevenTalkEntities DataContext
        //{
        //    get
        //    {
        //        return new SevenTalkEntities(_connectionString);
        //    }
        //}
    }
}
